/**
 * file: JobQueueServer.java
 */

package pcsd.server;

import java.rmi.Remote;
import java.rmi.RemoteException;

import pcsd.Task;
import pcsd.worker.JobProcessingWorker;

/**
 * A simple job queue server interface.
 * 
 * The server requires the workers to register themselves.
 * 
 * @author Tim van Deurzen
 */
public interface JobQueueServer extends Remote {

	/**
	 * Starts one task dispatcher thread per worker in the scheduler.
	 * 
	 * @param workers
	 *            - the workers available to execute tasks.
	 * @param m
	 *            - a monitor variable to be shared among thread dispatchers.
	 * @return see assignment description
	 * @throws RemoteException
	 */
	public int spawnWorkerThreads(JobProcessingWorker[] workers, Monitor m)
			throws RemoteException;

	/**
	 * Enqueues a task.
	 * 
	 * The server keeps a list of tasks it distributes among the workers.
	 * 
	 * @param task
	 *            - the task to be added to the queue of tasks.
	 * @return see assignment description
	 */
	public int enqueueTask(Task task) throws RemoteException;

}
